feat: add lefthand funbox for left-hand-only typing practice (@gokul1108)#7624
feat: add lefthand funbox for left-hand-only typing practice (@gokul1108)#7624gokul1108 wants to merge 1 commit into
Conversation
|
hi @gokul1108 , thank you for your contribution. You can already use the custom mode to do this:
|
There was a problem hiding this comment.
Pull request overview
Adds a new lefthand funbox to support left-hand-only typing practice by filtering the active word list down to words typeable with left-hand keys.
Changes:
- Extend
FunboxNameSchemawith"lefthand". - Register
lefthandin funbox metadata (description, difficulty, frontend function hook). - Implement
lefthand.withWordsto filter incoming word lists to left-hand-only words.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| packages/schemas/src/configs.ts | Adds lefthand to the funbox name enum for config validation/typing. |
| packages/funbox/src/list.ts | Adds funbox metadata entry so it appears in the funbox catalog and compatibility checks. |
| frontend/src/ts/test/funbox/funbox-functions.ts | Implements the frontend withWords hook to perform left-hand-only word filtering. |
| const LEFT_HAND_KEYS = new Set("qwertasdfgzxcvb"); | ||
| const filtered = (words ?? []).filter((w) => | ||
| [...w.toLowerCase()].every((ch) => LEFT_HAND_KEYS.has(ch)), |
There was a problem hiding this comment.
LEFT_HAND_KEYS is recreated on every withWords call. Consider hoisting the allowed-chars set/regex to module scope to avoid repeated allocations during word regeneration and keep this function simpler.
| lefthand: { | ||
| async withWords(words?: string[]): Promise<Wordset> { | ||
| const LEFT_HAND_KEYS = new Set("qwertasdfgzxcvb"); | ||
| const filtered = (words ?? []).filter((w) => | ||
| [...w.toLowerCase()].every((ch) => LEFT_HAND_KEYS.has(ch)), | ||
| ); | ||
| return new Wordset(filtered.length > 0 ? filtered : ["test"]); | ||
| }, |
There was a problem hiding this comment.
No unit test covers the new lefthand.withWords filtering behavior (allowed letters + empty-result handling). Since the repo already has Vitest coverage for funbox wiring (frontend/__tests__/test/funbox.spec.ts), consider adding a small test that asserts filtering works and that the empty-match case behaves as intended.
| description: "Only words typeable with the left hand.", | ||
| canGetPb: false, | ||
| difficultyLevel: 1, | ||
| properties: ["changesWordsFrequency"], |
There was a problem hiding this comment.
lefthand is marked changesWordsFrequency, which makes it incompatible with zipf (and any other frequency-changer) via funbox compatibility checks. Since this funbox filters the word list via withWords rather than changing selection frequency, consider removing changesWordsFrequency so lefthand can still be combined with zipf/future frequency modes.
| properties: ["changesWordsFrequency"], | |
| properties: [], |
| name: "weakspot", | ||
| }, | ||
| lefthand: { | ||
| description: "Only words typeable with the left hand.", |
There was a problem hiding this comment.
Funbox description says "Only words typeable with the left hand." but the implementation hardcodes QWERTY left-hand letters. This is user-facing text; either mention QWERTY explicitly here, or update the implementation to derive left-hand keys from the active layout (similar to the leftHand preset logic in frontend/src/ts/modals/word-filter.ts).
| description: "Only words typeable with the left hand.", | |
| description: "Only words typeable with the left hand on QWERTY.", |
| const filtered = (words ?? []).filter((w) => | ||
| [...w.toLowerCase()].every((ch) => LEFT_HAND_KEYS.has(ch)), | ||
| ); | ||
| return new Wordset(filtered.length > 0 ? filtered : ["test"]); |
There was a problem hiding this comment.
If the filtered list is empty, this returns new Wordset(["test"]), which silently replaces the user’s language/custom word list with a single placeholder word. Better to surface this as an unsupported scenario (e.g. show a notice, disable the funbox, and/or throw a WordGenError to trigger regeneration) so users aren’t stuck typing "test" repeatedly.
| return new Wordset(filtered.length > 0 ? filtered : ["test"]); | |
| if (filtered.length === 0) { | |
| throw new WordGenError( | |
| "No left-hand-only words available for the current word list.", | |
| ); | |
| } | |
| return new Wordset(filtered); |
Thanks for pointing that out! |
Description
Add a new "lefthand" funbox that filters words to only those typeable with the left hand on a QWERTY layout (keys:
qwertasdfgzxcvb). Useful for practicing weak left-hand typing.Changes:
packages/schemas/src/configs.ts— Added"lefthand"toFunboxNameSchemapackages/funbox/src/list.ts— Added funbox metadata entryfrontend/src/ts/test/funbox/funbox-functions.ts— ImplementedwithWordsthat filters language words to left-hand-only words